package com.zang.blogz.service.impl;

import com.zang.blogz.entity.FriendLink;
import com.zang.blogz.mapper.FriendLinkMapper;
import com.zang.blogz.model.output.FriendLinkViewVO;
import com.zang.blogz.service.FriendLinkService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 朵橙i
 * @since 2022-06-17
 */
@Service
public class FriendLinkServiceImpl extends ServiceImpl<FriendLinkMapper, FriendLink> implements FriendLinkService {

    @Override
    public List<FriendLinkViewVO> getFriendLinkViewVos() {

        ArrayList<FriendLinkViewVO> friendLinkViewVos = new ArrayList<>();

        list().forEach(friendLink ->
                friendLinkViewVos.add(
                        FriendLinkViewVO.builder()
                                .linkName(friendLink.getLinkName())
                                .linkIntro(friendLink.getLinkIntro())
                                .linkAvatar(friendLink.getLinkAvatar())
                                .linkAddress(friendLink.getLinkAddress()).build()));
        return friendLinkViewVos;
    }
}
